package net.lab1024.sa.admin.module.business.exam.service;

import java.util.List;
import net.lab1024.sa.admin.module.business.exam.dao.ExamrombDao;
import net.lab1024.sa.admin.module.business.exam.domain.entity.ExamrombEntity;
import net.lab1024.sa.admin.module.business.exam.domain.form.add.ExamrombAddForm;
import net.lab1024.sa.admin.module.business.exam.domain.form.query.ExamrombQueryForm;
import net.lab1024.sa.admin.module.business.exam.domain.form.update.ExamrombUpdateForm;
import net.lab1024.sa.admin.module.business.exam.domain.vo.ExamrombVO;
import net.lab1024.sa.base.common.util.SmartBeanUtil;
import net.lab1024.sa.base.common.util.SmartPageUtil;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.PageResult;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 日历明细 Service
 *
 * @Author AKITA
 * @Date 2025-06-06 11:36:12
 * @Copyright AKITA
 */

@Service
public class ExamrombService {

    @Resource
    private ExamrombDao examrombDao;

    /**
     * 分页查询
     */
    public PageResult<ExamrombVO> queryPage(ExamrombQueryForm queryForm) {
        Page<?> page = SmartPageUtil.convert2PageQuery(queryForm);
        List<ExamrombVO> list = examrombDao.queryPage(page, queryForm);
        return SmartPageUtil.convert2PageResult(page, list);
    }

    /**
     * 添加
     */
    public ResponseDTO<String> add(ExamrombAddForm addForm) {
        ExamrombEntity examrombEntity = SmartBeanUtil.copy(addForm, ExamrombEntity.class);
        examrombDao.insert(examrombEntity);
        return ResponseDTO.ok();
    }

    /**
     * 更新
     *
     */
    public ResponseDTO<String> update(ExamrombUpdateForm updateForm) {
        ExamrombEntity examrombEntity = SmartBeanUtil.copy(updateForm, ExamrombEntity.class);
        examrombDao.updateById(examrombEntity);
        return ResponseDTO.ok();
    }

    /**
     * 批量删除
     */
    public ResponseDTO<String> batchDelete(List<Long> idList) {
        if (CollectionUtils.isEmpty(idList)){
            return ResponseDTO.ok();
        }

        examrombDao.deleteBatchIds(idList);
        return ResponseDTO.ok();
    }

    /**
     * 单个删除
     */
    public ResponseDTO<String> delete(Long docEntry) {
        if (null == docEntry){
            return ResponseDTO.ok();
        }

        examrombDao.deleteById(docEntry);
        return ResponseDTO.ok();
    }
}
